package com.snail.app.gather.service;

import com.snail.app.gather.rep.SendFailDataRep;
import com.snail.app.gather.entity.SendFailData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * @description
 * @date 2021/12/17
 * @autor houyanfeng
 */
@Service
@Transactional
public class SendFailDataService {
    @Autowired
    private SendFailDataRep sendFailDataRep;

    public SendFailData getbyId(String id){
        Optional optional = sendFailDataRep.findById(id);
        if(optional.isPresent()){
            return (SendFailData)optional.get();
        }
        return null;
    }

    public void save(SendFailData entity){
        sendFailDataRep.save(entity);
    }

    public void del(String id){
        sendFailDataRep.deleteById(id);
    }


    public List<SendFailData> list(){
        return sendFailDataRep.findAll();
    }
    public List<SendFailData> listByRouterKey(String routerKey){
        return sendFailDataRep.execHql("from SendFailData where routingKey = '"+routerKey+"'");
    }
    /**
     * 查询指定时间后的数据
     * @param time yyyy-MM-dd HH:mm:ss:SSS
     * @return
     */
    public List<SendFailData> listAfterTime(String time){
        return sendFailDataRep.execHql("from SendFailData where createTime<='"+time+"'");
    }
}
